package com.csd.fragment;

import java.util.ArrayList;
import java.util.List;

import com.csd.activity.R;
import com.csd.adapter.PersonalAllAdapter;
import com.csd.bean.Car;
import com.csd.bean.PersonalOrder;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class PersonalAllFragment extends Fragment implements OnClickListener{

	private View view;
	private ListView listView;
	private PersonalAllAdapter adapter;
	private List<PersonalOrder> list;
	public static TextView tv_cancle;
	public static LinearLayout ll_cancle;
	private Button bt_no,bt_yes;
	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		view = inflater.inflate(R.layout.fragment_personalall, null);
		initView();
		return view;
	}
	private void initView() {
		// TODO Auto-generated method stub
		listView = (ListView) view.findViewById(R.id.all);
		list = new ArrayList<>();
		PersonalOrder order = new PersonalOrder();
		order.setOrderId("CWDD-0035");
		Car car = new Car();
		car.setImg(R.drawable.u120);
		car.setCarBrand("丰田威驰");
		car.setPlate("沪A-3245");
		order.setCar(car);
		order.setTakeTime("2014/11/19 18:00");
		order.setReturnTime("2014/11/19 20:00");
		order.setPayment(150);
		order.setState("待付款");
		
		PersonalOrder order1 = new PersonalOrder();
		order1.setOrderId("CWDD-0035");
		Car car1 = new Car();
		car1.setImg(R.drawable.u120);
		car1.setCarBrand("丰田威驰");
		car1.setPlate("沪A-3245");
		order1.setCar(car1);
		order1.setTakeTime("2014/11/19 18:00");
		order1.setReturnTime("2014/11/19 20:00");
		order1.setPayment(150);
		order1.setState("已付款");
		list.add(order1);
		list.add(order);
		adapter = new PersonalAllAdapter(list, getActivity());
		listView.setAdapter(adapter);
		ll_cancle = (LinearLayout) view.findViewById(R.id.ll_cancle);
		tv_cancle = (TextView) view.findViewById(R.id.tv_cancle);
		bt_no = (Button) view.findViewById(R.id.no);
		bt_yes = (Button) view.findViewById(R.id.yes);
		bt_no.setOnClickListener(this);
		bt_yes.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.no:
			ll_cancle.setVisibility(View.GONE);
			break;
		case R.id.yes:
			ll_cancle.setVisibility(View.GONE);
			break;
		default:
			break;
		}
	}
}
